import type { FormSchema } from '../types/form';

const adaptCompList = [
  'YearPicker',
  'MonthPicker',
  'DatePicker',
  'RangePicker',
  'TimePicker',
  'InputNumber',
  'Input',
  'Select',
  'Cascader',
];

// 获取组件默认宽度
export const getCompDefWidth = (component: string) => {
    if (adaptCompList.includes(component)) {
        return { 'minWidth': '210px', 'width': '100%' };
    }else{
        return {};
    }
};

/**
 * @description:  Set ui mount node
 */
export function getPopupContainer(node?: HTMLElement): HTMLElement {
    return (node?.parentNode as HTMLElement) ?? document.body;
}

// dynamic use hook props
export function getDynamicProps<T, U>(props: T): Partial<U> {
    const ret: Recordable = {};

    Object.keys((props as any)).map((key) => {
        ret[key] = unref((props as Recordable)[key]);
    });
    return ret as Partial<U>;
}